package com.myjavalab.dotsandboxes;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class User {

	private Board b;
	
	public User(Board b){
		this.b = b;
	}
	
	public void play(){		
		int row, column = 0;
		String inputStr = input();
		if(inputStr == null){
			return;
		}
		String[] arr = inputStr.trim().split(",");
		try {
			row = Integer.valueOf(arr[0].trim());
			column = Integer.valueOf(arr[1].trim());
			b.update(row, column);
		} catch (Exception e) {
			System.out.println("Wrong number entered");

		}
	}
	
	private String input(){
		String str;
		InputStreamReader stdin = new InputStreamReader(System.in);
		BufferedReader bufin = new BufferedReader(stdin);
		try {
			System.out.print("Please enter (row,column):  ");
			str = bufin.readLine();
			return str;
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(0);
			return "error";
		}
	}
	
}
